﻿using MxWeiXinPF.Common;
using MxWeiXinPF.Templates;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MxWeiXinPF.Web.shop
{
    public partial class userinfoold : MxWeiXinPF.Web.UI.UserPage
    {
        protected MxWeiXinPF.Model.users user_info;

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            if (base.errInitTemplates != "")
            {
                base.Response.Write(base.errInitTemplates);
            }
            else
            {
                base.templateFileName = new MxWeiXinPF.BLL.wx_module_templates().GetTemplatesFileNameByWid("shop", base.wid);
                if ((base.templateFileName == null) || (base.templateFileName.Trim() == ""))
                {
                    base.errInitTemplates = "不存在该帐号或者该帐号尚未设置模版！";
                    base.Response.Write(base.errInitTemplates);
                    base.Response.End();
                }
                else
                {
                    if (HttpContext.Current.Session["dt_session_user_info"] != null)
                    {
                        this.user_info = HttpContext.Current.Session["dt_session_user_info"] as MxWeiXinPF.Model.users;
                    }
                    base.serverPath = MyCommFun.GetRootPath() + "/shop/templates/" + base.templateFileName + "/userinfo.html";
                    ShopTemplateMgr mgr = new ShopTemplateMgr("/shop/templates/" + base.templateFileName, base.serverPath, base.wid, base.wid)
                    {
                        tType = TemplateType.userinfo
                    };
                    if ((user_info != null) && (!string.IsNullOrEmpty(this.user_info.wxOpenId)))
                    {
                        mgr.openid = this.user_info.wxOpenId;
                    }
                    else
                    {
                        mgr.openid = MyCommFun.RequestOpenid();
                    }
                    if ((MyCommFun.RequestParam("isMonth") != null) && MyCommFun.RequestParam("isMonth").Equals("1"))
                    {
                        mgr.isMonth = "1";
                    }
                    else
                    {
                        mgr.isMonth = "0";
                    }
                    mgr.OutPutHtml(base.wid);
                }
            }
        }
    }
}